<?php
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec");
ini_set("date.timezone", "Europe/Paris");
$this_day = now();
$pattern_year = "%Y";
$str_year = mdate($pattern_year, $this_day);

for ($i = 0; $i < 12; $i++) {
    $dropdown_data[$i + 1] = $months[$i];
}
for ($i = 0; $i < 31; $i++) {
    $day_data[$i + 1] = $i + 1;
}
for ($i = $str_year; $i > 1900; $i--) {
    $year_data[$i] = $i;
}
if (isset($error))
    echo $error;
?>
<?php
if ($admin_data->num_rows() > 0) {
    $admin = $admin_data->row();
    $date_long = $admin->dob;
    $adminid = $admin->id;
    $pattern = "%Y-%m-%d";
    $str_date = mdate($pattern, $date_long);
}

echo $erreur;
?>
<?php
$image_path = './assets/avatar/images/' . $admin->gravatar;
if ($admin->gravatar != '') {
    if (file_exists($image_path)) {
        $image_path = base_url() . 'assets/avatar/images/' . $admin->gravatar;
    } else {
        $image_path = base_url() . 'assets/noimage.gif';
    }
} else {
    $image_path = base_url() . 'assets/noimage.gif';
}
?>
<div id="news_detail_wrapper">
<div id="news_detail_act">Information</div>
 <?php if(validation_errors()!="") {?><div class="error_form"><?php echo validation_errors(); ?></div><?php } ?>
        <?php echo form_open_multipart(base_url() . 'index.php/accueil/edit_profile' . '/' . $adminid ); ?>
        <table align="center" class="list" cellpadding="5px" cellspacing="0" width="100%">
            <tr>
                <td>email:</td>
                <td><?php echo $admin->email; ?></td>
            </tr>
            <tr>
                <td>Display Name:</td>
                <td><input name="display_name" type="text" value="<?php echo $admin->display_name; ?>"/></td>
               
            </tr>
            <tr>
                <td>First_name:</td>
                <td><input name="first_name" type="text" value="<?php echo $admin->first_name; ?>"/></td>
           
            </tr>
            <tr>
                <td>Last name:</td>
                <td><input name="last_name" type="text" value="<?php echo $admin->last_name; ?>"/></td>
              
            </tr>
            <tr>
                <td rowspan="2">Avatar:</td>
                <td><img width="150" height="100" src="<?php echo $image_path; ?>"></td>
            </tr>
            <tr>
                <td><input name="userfile" id="userfile" type="file" size="25"/></td>
            </tr>
            <tr>
                <td>Company:</td> <td><input name="company" type="text" value="<?php echo $admin->company; ?>"/></td>
              
            </tr>
            <tr>
                <td>Gender</td>
                <td>
                    <?php
                    $gender = $admin->gender;

                    $male = array(
                        'name' => 'gender',
                        'id' => 'rad_male',
                        'value' => 'm',
                        'checked' => $gender == 'm' ? TRUE : FALSE,
                        'style' => 'margin:10px',
                    );
                    $female = array(
                        'name' => 'gender',
                        'id' => 'rad_female',
                        'value' => 'f',
                        'checked' => $gender == 'f' ? TRUE : FALSE,
                        'style' => 'margin:10px',
                    );

                    echo 'Male' . form_radio($male);
                    echo 'Female' . form_radio($female, 'Female');
                    ?>
                </td>
            </tr>
            <tr>
                <td><label for="birthday">Birthday :</label></td>
                <td>
                    D : <?php echo form_dropdown('birth_date', $day_data, get_date_part($str_date, 'day'), 'id="day"'); ?>
                    M : <?php echo form_dropdown('birth_month', $dropdown_data, get_date_part($str_date, 'month'), 'id="month"'); ?>
                    Y : <?php echo form_dropdown('birth_year', $year_data, get_date_part($str_date, 'year'), 'id="year"'); ?>
                </td>
            </tr>
            <tr>
                <td>Phone:</td>
                <td><input name="phone" type="text" value="<?php echo $admin->phone; ?>"/></td>
               
            </tr>
            <tr>
                <td>Mobile:</td>
                <td><input name="mobile" type="text" value="<?php echo $admin->mobile; ?>"/></td>
            
            </tr>
            <tr> 
                <td>Address:</td> <td><input name="address" type="text" value="<?php echo $admin->address; ?>"/></td>
            
            </tr>
            <tr>
                <td></td><td><input type="submit" name="submit" value="Enregistrer"/></td>
            </tr>
        </table>
   
    <?php echo form_close() ?>

</div>
